#include <stdio.h>

#define DEBUG
#include "alg.h"

int
main(int argc, char **argv)
{
	int num;
	char word[60];
	struct vector *v[2];
	int i;

	v[0] = vector__new(sizeof (int), -1);
	v[1] = vector__new(sizeof word, 0);

	while (scanf("%d", &num) == 1) {
		(void) snprintf(word, sizeof word, "%+5.3d", num);
		vector__append(v[0], &num);
		vector__append(v[1], word);
	}

	printf("elements from v[0]: %p %p %p %p\n",
			vector__get_by_idx(v[0], -1),
			vector__get_by_idx(v[0], 0),
			vector__get_by_idx(v[0], 5),
			vector__get_by_idx(v[0], 1337));
	printf("elements from v[1]: \'%s\' \'%s\' \'%s\' \'%s\'\n",
			vector__get_by_idx(v[1], -1),
			vector__get_by_idx(v[1], 0),
			vector__get_by_idx(v[1], 5),
			vector__get_by_idx(v[1], 1337));

	for (i = 0; i < v[0]->n && i < v[1]->n; i++) {
		printf("%d: %d\t\'%s\'\n", i, *(int*)vector__get_by_idx(v[0], i),
				vector__get_by_idx(v[1], i));
	}

	puts("freeing v[0]");
	vector__cleanup(v[0]);
	puts("freeing v[1]");
	vector__cleanup(v[1]);

	return 0;
}
